<template>
  <div class="avue-crud">
    <el-table :data="dataList" :height="tableHeight==null?'calc((100vh - 80px - 70px) / 2 - 200px)':tableHeight" border style="min-height: 100px;">
      <!-- <el-table-column label="审批编号" prop="ywMainCode" align="center" min-width="120px"></el-table-column>
      <el-table-column label="审批名称" prop="ywTitle" header-align="center" align="left" min-width="250px"></el-table-column> -->
      <el-table-column label="当前节点" prop="taskName" align="center" width="400px"></el-table-column>
      <el-table-column label="发起人" prop="userName" align="center" width="200px"></el-table-column>
      <el-table-column label="任务数量" prop="cou" align="center" width="90px" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-if="scope.row.cou == 0">1</span>
          <span v-else>{{scope.row.cou}}</span>
        </template>
      </el-table-column>
      <el-table-column label="接收时间" prop="ksTime" align="center" >
        <template slot-scope="scope">{{$moment(scope.row.ksTime).format("YYYY-MM-DD HH:mm")}}</template>
      </el-table-column>
      <el-table-column label="操作" align="center" min-width="100" max-width="100">
        <template slot-scope="scope">
          <el-button  type="primary" plain @click="shenhe(scope.row)">审批办理</el-button>
          <!-- <el-button  type="primary" plain @click="handleDialog(scope.row)">审批办理</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <div class="avue-crud__pagination">
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
                     :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background
                     layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </div>
    <workflow ref="workflow" @refreshDataList="getDataList"></workflow>
    <workflow ref="workflow" @refreshDataList="getDataList" @refreshTableData="getDataList"></workflow>
  </div>
</template>

<script>
import {wddbpage} from "@/api/workflow/wfywmain";
import workflow from '@/views/workflow/apply/index'

import store from '@/store'
import {
  mapGetters
} from 'vuex'

export default {
  data() {
    return {
      dataForm: {
        key: ''
      },
      dataFormSzbg: {
        id: 0,
        szbgFjmc: '',
        szbgFjlx: '',
        szbgFjdz: '',
        szJzDate: ''
      },
      bgdialogVisible: false,
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      cepinghdgulszbgUploadFormVisible: false,
      headers: {
        Authorization: 'Bearer ' + store.getters.access_token
      },
      bgUrl: ""
    }
  },
  created() {
    this.getDataList();
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  props: {
    tableHeight: {
      type: String,
      default: null
    }
  },
  components: {
    workflow
  },
  methods: {

    // shenhe(row){
    //     this.$router.push({path: '/hetongrenwu/hetong/hetongqianding/hetongsh/index'})
    // },
    shenhe(row){
        //指标审核串行usertask3  并行usertask4
        if(row.nodeKey==='usertask3' || row.nodeKey==='usertask4' ){
          this.$router.push({path: '/hetongrenwu/hetong/hetongyeji/hetongzbsh/index'})
          //文本审核串行 usertask6 并行usertask7
        }else if(row.nodeKey==='usertask6' || row.nodeKey==='usertask7' ){
          this.$router.push({path: '/hetongrenwu/hetong/hetongyeji/hetongwbsh/index'})
          //合同审核 usertask9 usertask10  myself
        }else if(row.nodeKey==='usertask9' || row.nodeKey==='usertask10'|| row.nodeKey==='myself' ){
          this.$router.push({path: '/hetongrenwu/hetong/hetongqianding/hetongsh/index'})
          //填报审核 usertask11 usertask11b
        }else if(row.nodeKey==='usertask11' || row.nodeKey==='usertask11b'){
          this.$router.push({path: '/hetongrenwu/hetong/hetongtb/hetongtbsh/index'})
          //领导审核 usertask13 usertask14
        }else if(row.nodeKey==='usertask13' || row.nodeKey==='usertask14'){
          this.$router.push({path: '/hetongrenwu/hetong/hetongtb/hetongqtjc/index'})
        }

        //专项工作及日常考核新增开始
        else if(row.nodeKey==='qc'){
            this.$router.push({path: '/hetongrenwu/specialWork/createWork/createWork'})
        }else if(row.nodeKey==='qcjlsp' || row.nodeKey==='zbjlsp'|| row.nodeKey==='xbjlsp' ){
            this.$router.push({path: '/hetongrenwu/specialWork/workExamine/index'})
            //填报审核 usertask11 usertask11b
        }else if(row.nodeKey==='cyrjlsp') {
            this.$router.push({path: '/hetongrenwu/specialWork/joinPerConfirm/index'})
        }
        else if(row.nodeKey==='khyqc') {
            this.$router.push({path: '/dailyExamine/eventExamine/createEvent/index'})
        }
        else if(row.nodeKey==='sjshsjshcx' || row.nodeKey==='sjshsjshbx') {
            this.$router.push({path: '/dailyExamine/eventExamine/eventExamine/index'})
        }else if(row.nodeKey==='sjshjxwzysh' || row.nodeKey==='sjshwyhcx'|| row.nodeKey==='sjshwyhbx'){
            this.$router.push({path: '/dailyExamine/eventExamine/eventReview/index'})
        }else if(row.nodeKey==='khyqr') {
            this.$router.push({path: '/dailyExamine/eventExamine/resultsConfirm/index'})
        }

        else if(row.nodeKey==='zbkhycj') {
            this.$router.push({path: '/dailyExamine/targetExamine/createAssessment/index'})
        }
        else if(row.nodeKey==='khzbnd') {
            this.$router.push({path: '/dailyExamine/targetExamine/indicatorFormulation/index'})
        }
        else if(row.nodeKey==='khzbshcx' || row.nodeKey==='khzbshbx'){
            this.$router.push({path: '/dailyExamine/targetExamine/indexReview/index'})
        }
        else if(row.nodeKey==='sjkhwyhzy'||row.nodeKey==='sjkhwyhcx' || row.nodeKey==='sjkhwyhbx') {
            this.$router.push({path: '/dailyExamine/targetExamine/indexExamine/index'})
        }
        else if(row.nodeKey==='khyfqtb') {
            this.$router.push({path: '/dailyExamine/InitiateFilling/InitiateFilling/index'})
        }
        else if(row.nodeKey==='khzbtb') {
            this.$router.push({path: '/dailyExamine/InitiateFilling/resultFilling/index'})
        }
        else if(row.nodeKey==='khjgtbcx' || row.nodeKey==='khjgtbbx'){
            this.$router.push({path: '/dailyExamine/InitiateFilling/fillingAndApproval/index'})
        }
        else if(row.nodeKey==='khldhz'||row.nodeKey==='khldshcx' || row.nodeKey==='khldshbx') {
            this.$router.push({path: '/dailyExamine/InitiateFilling/resultAudit/index'})
        }
        else if(row.nodeKey==='khbkhrqr') {
            this.$router.push({path: '/dailyExamine/InitiateFilling/resultsConfirm/index'})
        }
		else if(row.nodeKey==='bmhzcj') { //评分汇总开始

			this.$router.push({path: '/statisticsanalysis/departSummary/index'})
		}
		else if(row.nodeKey==='bmldspcx' || row.nodeKey==='bmldspbx'){
			this.$router.push({path: '/statisticsanalysis/leaderReview/index'})
		}
		else if(row.nodeKey==='pfzycj') {
			this.$router.push({path: '/statisticsanalysis/leaderSummary/index'})
		}
		else if(row.nodeKey==='pfzyhz') {
			this.$router.push({path: '/statisticsanalysis/commissionerSummary/index'})
		}
		else if(row.nodeKey==='pfldshfg' || row.nodeKey==='pfldshcx'||row.nodeKey==='pfldshbx'){
			this.$router.push({path: '/statisticsanalysis/secondaryLeaderReview/index'})
		}//评分汇总结束
		//专项工作及日常考核新增结束
    },

    formater(row, column, cellValue, index) {
      if (cellValue) {
        return this.$moment(cellValue).format("yyyy-MM-DD HH:mm");
      } else {
        return cellValue;
      }
    },
    // 获取数据列表 预览分页查询使用
    getDataList() {
      this.dataListLoading = true
      wddbpage(Object.assign({
        current: this.pageIndex,
        size: this.pageSize
      })).then(response => {
        this.dataList = response.data.data.records
        this.totalPage = response.data.data.total
      })
      this.dataListLoading = false
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    handleDialog(r) {
      this.$refs.workflow.open(r.ywId)
    }
  }
}

</script>

